<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Index_Rss extends Controller_Base {

    public function before() {
        parent::before();
    }

    public function action_index() {
        $this->auto_render = false;
        $info = array(
            'title' => 'Новини сайту',
            'language' => 'ua',
            'description' => 'Новини від Музичного магазину',
            'link' => 'http://kohana/rss',
            'pubDate' => time());

        $news = Model::factory('news')->last_news();

        foreach ($news as $key => $new) {
            $url = 'http://kohana/news/';
            $items[] = array(
                'title' => $key,
                'link' => $url,
                'guid' => $url,
                'description' => Text::limit_chars($new, 100).'...',
                'pubDate' => 'no data'
            );
        }
        
        header('Content-Type: text/xml');
        echo Feed::create($info, $items);
    }
}

